package com.example.administrator.basepro.ui.presenter;

import com.blankj.utilcode.util.LogUtils;
import com.example.administrator.basepro.base.RxPresenter;
import com.example.administrator.basepro.model.DataManager;
import com.example.administrator.basepro.model.bean.LoginBean;
import com.example.administrator.basepro.model.bean.TableOpeBean;
import com.example.administrator.basepro.ui.contract.SubmitSecureContract;
import com.example.administrator.basepro.utils.RxUtil;

import javax.inject.Inject;

import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/9/1 0001.
 */

public class SubmitSecurePresenter extends RxPresenter<SubmitSecureContract.View> implements SubmitSecureContract.Presenter {


    private DataManager dataManager;
    @Inject
    public SubmitSecurePresenter(DataManager dataManager) {
        this.dataManager = dataManager;
    }

    @Override
    public void submit(RequestBody bean) {
        addSubscribe(dataManager.submitSecure(bean).compose(RxUtil.<LoginBean>rxSchedulerHelper()).subscribe(new Consumer<LoginBean>() {
            @Override
            public void accept(@NonNull LoginBean bean) throws Exception {
                mView.show(bean);// TODO: 2017/9/1 0001
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(@NonNull Throwable throwable) throws Exception {
                LogUtils.v(throwable.toString());
            }
        }));
    }
}
